var http = require('http'),
    url = require('url');

http.createServer(function (req, res) {
    var pathname = url.parse(req.url).pathname;
    if (pathname === '/') {
        res.writeHead(200, {
            'Content-Type': 'text/plain'
        });
        res.end('Home Page');
    } else if (pathname === '/about') {
        res.writeHead(200, {
            'Content-Type': 'text/plain'
        });
        res.end('About Us');
    } else if (pathname === '/redirect') {
        res.writeHead(301, {
            'Location': 'http://www.baidu.com'
        });
        res.end('go to baidu');
    } else {
        res.writeHead(404, {
            'Content-Type': 'text/html'
        });
        res.end('Page not found');
    }
}).listen(3000, '127.0.0.1');
